package com.j180.service.impl;

import com.j180.bean.StudentBean;
import com.j180.dao.IStudentDao;
import com.j180.service.IStudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service(value = "studentServiceImpl")
public class StudentServiceImpl  implements IStudentService {

     //@Autowired  是spring注解  默认是以byType的方式进行注入
     @Resource //是java的注解 默认是byNamer,如果找不到name 在以byType的查询
     private IStudentDao iStudentDao;

    public void setiStudentDao(IStudentDao iStudentDao) {
        System.out.println("iStudentDao被注入");

        this.iStudentDao = iStudentDao;
    }

    @Override
    public void addStudent(StudentBean student) {

        iStudentDao.insertStudent(student);
    }

    @Override
    public List<StudentBean> showStudents() {

        return iStudentDao.getStudents();
    }

    @Override
    public StudentBean showStudentById(int id) {
        return iStudentDao.getStudentById(id);
    }

    @Override
    public int updateStudentInfo(StudentBean studentBean) {
        return iStudentDao.updateStudent(studentBean);
    }

    @Override
    public int deleteStudentInfo(int studentId) {
        return iStudentDao.deleteStudentById(studentId);
    }


}
